package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.system.domain.TbCarSell;
import com.ruoyi.system.domain.TbCarTypo;
import com.ruoyi.system.service.ITbCarTypoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbCarStorage;
import com.ruoyi.system.service.ITbCarStorageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2020-06-27
 */
@Controller
@RequestMapping("/system/storage")
public class TbCarStorageController extends BaseController
{
    private String prefix = "system/storage";

    @Autowired
    private ITbCarStorageService tbCarStorageService;
    @Autowired
    private ITbCarTypoService tbCarTypoService;

    @RequiresPermissions("system:storage:view")
    @GetMapping()
    public String storage()
    {
        return prefix + "/storage";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("system:storage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbCarStorage tbCarStorage)
    {
        startPage();
        List<TbCarStorage> list = tbCarStorageService.selectTbCarStorageList(tbCarStorage);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("system:storage:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TbCarStorage tbCarStorage)
    {
        List<TbCarStorage> list = tbCarStorageService.selectTbCarStorageList(tbCarStorage);
        ExcelUtil<TbCarStorage> util = new ExcelUtil<TbCarStorage>(TbCarStorage.class);
        return util.exportExcel(list, "storage");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("system:storage:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TbCarStorage tbCarStorage)
    {
        return toAjax(tbCarStorageService.insertTbCarStorage(tbCarStorage));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{storageId}")
    public String edit(@PathVariable("storageId") Long storageId, ModelMap mmap)
    {
        TbCarStorage tbCarStorage = tbCarStorageService.selectTbCarStorageById(storageId);
        mmap.put("tbCarStorage", tbCarStorage);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("system:storage:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbCarStorage tbCarStorage)
    {
        return toAjax(tbCarStorageService.updateTbCarStorage(tbCarStorage));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:storage:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbCarStorageService.deleteTbCarStorageByIds(ids));
    }



    @RequestMapping("tan")
    @ResponseBody
    @PostMapping("/list")
    public List<TbCarSell> xl(TbCarSell tbCarSell){
        List<TbCarSell>  list = tbCarStorageService.tan(tbCarSell);
        return list;
    }

    @RequestMapping("xl")
    @ResponseBody
    @PostMapping
    public List<TbCarTypo> xl(TbCarTypo tbCarTypo){
        List<TbCarTypo> list =  tbCarStorageService.xl(tbCarTypo);
        return list;
    }
}
